package com.wf.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

@RefreshScope
@RestController
class TestController {
   // @Autowired
   // private RedisTemplate redisTemplate;

    @Value("${from}")
    private String from;
    @RequestMapping("/from")
    public String from() {
        return this.from;
    }

    /**
     * redis缓存测试
     */
    @RequestMapping("/redis")
    public void redis() {
        //ValueOperations<String, String> operations = redisTemplate.opsForValue();
        //operations.set("test","test", 10, TimeUnit.SECONDS);
        //String ss=operations.get("test");
        // System.out.print(ss);
    }

    /**
     * redis session缓存测试
     * @param session
     */
    @RequestMapping("/session")
    public void session(HttpSession session) {
//        UUID uid = (UUID) session.getAttribute("uid");
//        if (uid == null) {
//            uid = UUID.randomUUID();
//        }
//        session.setAttribute("uid", uid);
        //System.out.print(session.getId());
    }
}